package com.example.exp_4;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

public class Menu extends AppCompatActivity {
    Dialog dialog;
    Contact contact;
    Setting setting;
    Button btn1,btn2,btn3,btn4,btn5;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        btn1 = findViewById(R.id.btn_dialog);
        btn2 = findViewById(R.id.btn_contact);
        btn3 = findViewById(R.id.btn_setting);
        dialog = new Dialog();
        getSupportFragmentManager().beginTransaction().add(R.id.framelayout,dialog).commitAllowingStateLoss();
        btn1.setOnClickListener(v -> {
            if (dialog == null) {
                dialog = new Dialog();
            }
            getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,dialog).commitAllowingStateLoss();
        });
        btn2.setOnClickListener(v -> {
            if (contact == null) {
                contact = new Contact();
            }
            getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,contact).commitAllowingStateLoss();
        });
        btn3.setOnClickListener(v -> {
            if (setting == null) {
                setting = new Setting();
            }
            getSupportFragmentManager().beginTransaction().replace(R.id.framelayout,setting).commitAllowingStateLoss();
        });
    }
    public void changeinfo(View view) {
        Intent intent = new Intent(Menu.this,ChangeInfo.class);
        startActivity(intent);
    }
    public void quit(View view) {
        Intent intent = new Intent(Menu.this,MainActivity.class);
        startActivity(intent);
    }
}
